package com.ruoyi.wareManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wareManagement.domain.ScrapInventoryInquiry;
import com.ruoyi.wareManagement.service.IScrapInventoryInquiryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报废库存查询Controller
 * 
 * @author admin
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/wareManagement/scrapInventoryInquiry")
public class ScrapInventoryInquiryController extends BaseController
{
    @Autowired
    private IScrapInventoryInquiryService scrapInventoryInquiryService;

    /**
     * 查询报废库存查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:scrapInventoryInquiry:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScrapInventoryInquiry scrapInventoryInquiry)
    {
        startPage();
        List<ScrapInventoryInquiry> list = scrapInventoryInquiryService.selectScrapInventoryInquiryList(scrapInventoryInquiry);
        return getDataTable(list);
    }

    /**
     * 导出报废库存查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:scrapInventoryInquiry:export')")
    @Log(title = "报废库存查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScrapInventoryInquiry scrapInventoryInquiry)
    {
        List<ScrapInventoryInquiry> list = scrapInventoryInquiryService.selectScrapInventoryInquiryList(scrapInventoryInquiry);
        ExcelUtil<ScrapInventoryInquiry> util = new ExcelUtil<ScrapInventoryInquiry>(ScrapInventoryInquiry.class);
        util.exportExcel(response, list, "报废库存查询数据");
    }

    /**
     * 获取报废库存查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:scrapInventoryInquiry:query')")
    @GetMapping(value = "/{scrapId}")
    public AjaxResult getInfo(@PathVariable("scrapId") Long scrapId)
    {
        return success(scrapInventoryInquiryService.selectScrapInventoryInquiryByScrapId(scrapId));
    }

    /**
     * 新增报废库存查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:scrapInventoryInquiry:add')")
    @Log(title = "报废库存查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScrapInventoryInquiry scrapInventoryInquiry)
    {
        return toAjax(scrapInventoryInquiryService.insertScrapInventoryInquiry(scrapInventoryInquiry));
    }

    /**
     * 修改报废库存查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:scrapInventoryInquiry:edit')")
    @Log(title = "报废库存查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScrapInventoryInquiry scrapInventoryInquiry)
    {
        return toAjax(scrapInventoryInquiryService.updateScrapInventoryInquiry(scrapInventoryInquiry));
    }

    /**
     * 删除报废库存查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:scrapInventoryInquiry:remove')")
    @Log(title = "报废库存查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scrapIds}")
    public AjaxResult remove(@PathVariable Long[] scrapIds)
    {
        return toAjax(scrapInventoryInquiryService.deleteScrapInventoryInquiryByScrapIds(scrapIds));
    }
}
